#ifndef MUSIC_H
#define MUSIC_H

#include <QWidget>
#include <handleobj.h>

#define localmusicPath "F:\\QtProjects\\MediaPlayer\\musicApp\\localmusic\\" //本地音乐路径

#define singleSongMode 1 // 单曲循环
#define loopSongMode   0 // 列表循环
#define randomSongMode 2 // 随机播放

#define blackClouth "background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:1, stop:0 rgba(32, 32, 32, 255), stop:1 rgba(255, 255, 255, 255));}"
#define pinkClouth  "background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:1, stop:0 rgba(200, 44, 106, 255), stop:1 rgba(255, 255, 255, 255));}"
#define redClouth   "background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:1, stop:0 rgba(255, 0, 0, 255), stop:1 rgba(255, 255, 255, 255));}"
#define blueClouth  "background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:1, stop:0 rgba(0, 179, 255, 255), stop:1 rgba(255, 255, 255, 255));}"
#define greenClouth "background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:1, stop:0 rgba(0, 168, 0, 255), stop:1 rgba(255, 255, 255, 255));}"

#define blackClouthMode 0
#define pinkClouthMode  2
#define redClouthMode   4
#define blueClouthMode  1
#define greenClouthMode 3

#define localMode     0
#define navidromeMode 1

namespace Ui {
class music;
}

class music : public HandleObj
{
    Q_OBJECT

public:
    explicit music(QWidget *parent = nullptr);
    ~music();
    void getNavidromeSongList();
    void playNavidromeSong(int index);
    void getNavidromeSongWords(int index);
    void loginNavidrome();
    void searchNavidromeSongList(QString query);

private:
    Ui::music *ui;
    QList<QUrl> localmusicList;
    QList<qint64> songtimesList;
    QAudioOutput *audioOutput;
    QMediaPlayer *mediaPlayer;
    QScrollBar *songwordsscrollBar;
    QString songWords;
    QString navidromeToken;
    QString navidromeID;
    int songplayMode = 0;
    int songtimesNum = 0;
    int songlistNum = 0;
    int songlastPos = 0;
    bool songlistMode = 0;

    struct songNavidrome
    {
        QList<QString> titles;    // 存储曲名
        QList<QString> albums;    // 存储专辑
        QList<QString> artists;   // 存储歌手
        QList<QString> ids;       // 存储歌曲id
    };
    songNavidrome navidrome;

protected:
    // void closeEvent(QCloseEvent *event);
    bool eventFilter(QObject *obj, QEvent *event);

private slots:
    void on_FileSongButton_clicked();
    void on_PlaySongButton_clicked();
    void on_LastSongButton_clicked();
    void on_NextSongButton_clicked();
    void on_ModeSongButton_clicked();
    void on_VoiceSongButton_clicked();
    void on_ClothButton_clicked();
    void on_WiFiSongButton_clicked();
    void on_SearchSongButton_clicked();
};


#endif // MUSIC_H
